package Operations;
import Book.Book;
import Book.BookList;

import java.util.Scanner;

public class FindOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        //查找图书
        System.out.println("查找图书!");
        System.out.println("请输入你要查找的图书名:");
        Scanner sc = new Scanner(System.in);
        String name = sc.nextLine();

        int size = bookList.getNumBook();
        for (int i = 0; i < size; i++) {
            Book book = bookList.getpos(i);
            if(name.equals(book.getBookname()))
            {
                System.out.println("找到了这本书！");
                System.out.println(book);
                return ;
            }
        }
        System.out.println("没有找到这本书！");
    }
}
